package com.wonders.common.config.manager.instance;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.wonders.common.constant.CommonConstant;
import com.wonders.common.parse.jaxb.config.JaxbConfig;
import com.wonders.common.ws.constant.XtptConstant;
import com.wonders.framework.config.manager.BaseManager;

/**
 * JAXB配置管理器
 * 
 * @author WuBin
 * 
 */
@Component
public class JaxbConfigManager implements BaseManager {

	/**
	 * XSD文件目录
	 */
	@Value("${jaxb.xsdPath}")
	private String xsdPath;

	@Autowired
	private JaxbConfig jaxbConfig;

	public void destroy() {

	}

	public void init() {
		if (StringUtils.isEmpty(xsdPath)) {
			return;
		}
		jaxbConfig.addXsdConfig(XtptConstant.GLOBAL_HEAD,
				CommonConstant.Interaction.REQ,
				"com.wonders.common.ws.mapping.bean.global.Head",
				"com/wonders/common/ws/mapping/xsd/global/Head.xsd");
		jaxbConfig.addXsdConfig(XtptConstant.GLOBAL_HEAD,
				CommonConstant.Interaction.RES,
				"com.wonders.common.ws.mapping.bean.global.Head",
				"com/wonders/common/ws/mapping/xsd/global/Head.xsd");
		jaxbConfig.addXsdConfig(XtptConstant.GLOBAL_TRADEMSG,
				CommonConstant.Interaction.REQ,
				"com.wonders.common.ws.mapping.bean.global.TradeMsg",
				"com/wonders/common/ws/mapping/xsd/global/TradeMsg.xsd");
		jaxbConfig.addXsdConfig(XtptConstant.GLOBAL_TRADEMSG,
				CommonConstant.Interaction.RES,
				"com.wonders.common.ws.mapping.bean.global.TradeMsg",
				"com/wonders/common/ws/mapping/xsd/global/TradeMsg.xsd");
		jaxbConfig.scanConfig(xsdPath);
	}

}
